function [best_lambda, best_gamma, best_acc] = rda_grid_search(Training_Samples, Testing_Samples, Training_Labels, Testing_Labels)
test_rows = size(Testing_Samples, 1);
best_lambda=0;
best_gamma=0;
best_acc=0;
for lambda = 0.025:0.025:1,
    for gamma = 0.025:0.025:1,
        rda_out = rda(Training_Samples, Testing_Samples, Training_Labels, lambda, gamma);

        matches = 0;
        for d = 1:1:test_rows,
            row = rda_out(d:d,:);
            min_row_el = min(row);
            ind = find(row<=min_row_el, 1, 'first');
            if ind == Testing_Labels(d),
                matches = matches + 1;
            end
        end

        accuracy = (matches/test_rows)*100;
        fprintf('Current accuracy: %g, lambda=%g, gamma=%g.\n', accuracy, lambda, gamma);

        if accuracy > best_acc,
            best_acc = accuracy;
            best_lambda = lambda;
            best_gamma = gamma;
        end
    end
end
end